<?php

namespace app\modules\setting\models\workspaces;

use yii\helpers\Json;

/**
 * This is the model class for table "{{%set_workspaces_sjdl}}".
 *
 * @property int $id
 * @property string $responseid 结果id
 * @property string $res 结果集
 * @property string $email 邮箱
 * @property string $nickname 昵称
 * @property string $avatar 头像
 * @property string $followers 粉丝数
 * @property string $hearts 点赞数
 * @property string $videos_count 视频数
 * @property string $following 关注数
 * @property string $influencer_id influencer_id
 * @property string $biography biography
 * @property string $bio_link bio_link
 * @property string $update_at 最后更新时间
 */
class SetWorkspacesSjdl extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%set_workspaces_sjdl}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['responseid', 'res', 'email', 'nickname', 'avatar', 'followers', 'hearts', 'videos_count', 'following', 'influencer_id', 'biography', 'update_at','bio_link'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            
            'id' => 'ID',
            
            'responseid' => '结果id',
            
            'res' => '结果集',
            
            'email' => '邮箱',
            
            'nickname' => '昵称',
            
            'avatar' => '头像',
            
            'followers' => '粉丝数',
            
            'hearts' => '点赞数',
            
            'videos_count' => '视频数',
            
            'following' => '关注数',
            
            'influencer_id' => 'influencer_id',
            
            'biography' => 'biography',
                                    
            'update_at' => '最后更新时间',
        ];
    }


    public function beforeValidate()
    {
        foreach ($this->attributes() as $field){
            if (is_array($this->$field)){
                $this->$field = Json::encode($this->$field);
            }
        }

        return parent::beforeValidate(); // TODO: Change the autogenerated stub
    }

    public function getFirstErrorStr()
    {
        $errors = $this->getErrors();

        if ($errors){
            foreach ($errors as $item){
                return $item[0];
            }
        }

        return "";
    }
}
